package com.example.check_oa.controller;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.check_oa.model.mapper.ReplacementCardApMapper;
import com.example.comment_oa.pojos.attendance.ReplacementCardAp;
import com.example.check_oa.model.service.ReplacementCardApService;
import com.example.comment_oa.response.AjaxResponse;
import org.apache.commons.io.FilenameUtils;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.UUID;

@RestController
@RequestMapping("checkOa/replace")
@CrossOrigin
public class ReplaceController {
    @Resource
    ReplacementCardApService replacementCardApService;
    @Resource
    ReplacementCardApMapper replacementCardApMapper;

    //新增补卡记录
    @PostMapping("add")
    public AjaxResponse add(ReplacementCardAp replacementCardAp,MultipartFile file){
        return AjaxResponse.success(replacementCardApService.add(replacementCardAp,file));
    }

    //查询近三天缺卡
    @PostMapping("selectNo/{userNo}")
    public AjaxResponse selectNo(@PathVariable("userNo") String usreNo){
        return AjaxResponse.success(replacementCardApService.selectNo(usreNo));
    }

    //查询本月补卡信息
    @PostMapping("query/{userNo}/{date}")
    public AjaxResponse query(@PathVariable("userNo")String userNo,@PathVariable("date") String date){
        System.err.println("2345"+userNo);
        return AjaxResponse.success(replacementCardApService.quer(userNo,date));
    }

    @PostMapping("selectByWate/{water}")
    public AjaxResponse sele(@PathVariable("water")String water){
        return AjaxResponse.success(replacementCardApMapper.selectByWater(water));
    }

    @PostMapping("yes")
    public AjaxResponse yesRc(){
        return AjaxResponse.success(replacementCardApService.yesRc(DateUtil.formatDate(new Date()).substring(0,7),"TR1003","applycard202302091747","hh"));
    }

    @PostMapping("no")
    public AjaxResponse noRc(){
        return AjaxResponse.success(replacementCardApService.noRc("applycard202302091747","hh"));
    }
}
